package com.asset.dispoal.business.appoint.service.command;

import com.asset.dispoal.business.appoint.domain.db.mapper.AppointMapper;
import com.asset.dispoal.business.appoint.dto.AppointPageResponse;
import com.asset.dispoal.business.appoint.dto.QueryDropAppointRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.ddd.BaseCommand;
import tech.mhuang.pacebox.springboot.core.local.GlobalHeaderThreadLocal;
import tech.mhuang.pacebox.springboot.protocol.Result;

import java.util.List;

@Component
@Slf4j
public class QueryDropAppointCommand implements BaseCommand<QueryDropAppointRequest, Result<List<AppointPageResponse>>> {

    @Autowired
    AppointMapper appointMapper;

    @Override
    public Result<List<AppointPageResponse>> execute(QueryDropAppointRequest request) {
        String permission = (String) GlobalHeaderThreadLocal.getOrException().getExtraMap().get("permission");
        request.setPermission(permission);
        return Result.ok(appointMapper.queryDropByAssetInstBatchId(request));
    }
}
